home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 2004 #11
/
Amiga Plus CD - 2004 - No. 11.iso
/
AmiSoft
/
Dev
/
misc
/
temgen.lha
/
Temgen
/
tg-0.11
/
sample
/
docex
/
docex.tg
next >
Wrap
Text File
|
2002-12-18
|
5KB
|
179 lines
#
# Examples from user manual
#
#############################################
@ $name = "Alaska"
$name is the best !
@ $name = "Alaska"
(zmienna \$name)
@ $s = "BAR"
@ $n = 2
@ $tab[1] = "foo"
@ $tab[2] = "bar"
@ $str = [ name: "FOO", count: 4 ]
$s $tab[ 1 ] $tab[ $n ]
$str.name, $str.count
@ $tab = ["a","b","c",1000]
@ $str = [ name: "FOO", count: 4, val: 1.20 ]
@for ($i=0; $i<$size($tab); $i++)
item $i: $tab[ $i ]
@endfor
STRUCTURE:
@for ($i in $str)
$i: $str.$i
@endfor
@ $data = [ "scalar", [a:"Alaska", b:"Bar"], \
@ [1,2,3,4], \
@ 10 ]
@function fun()
inline text
@ return "RESULT TEXT"
@endfunction
called from data line: $fun()
@ $fun()
@for ( $i=0; $i<10; $i++ )
iteration $i
@ break
@endfor
@switch ( 1 )
@ case 1:
branch 1
@ break
@ case 2:
branch 2
@endswitch
@push
@embed "header"
@embed "body"
@embed "footer"
@emit "body"
BODY TEXT
@emit "footer"
FOOTER TEXT
@emit "header"
HEADER TEXT
@pop
@for ( $i=0; $i<3; $i++ )
item $i
@endfor
@ $str = [ a: "FOO", b: "BAR" ]
@for ( $fld in $str )
$fld: $str.$fld
@endfor
@function factor( n )
@ if ( $n == 1 )
@ return 1
@ else
@ return $n * $factor( $n - 1 )
@ endif
@endfunction
@for ( $i=1; $i<8; $i++ )
$i ! = $factor($i)
@endfor
@function abc(a,b)
@local c
$a $b $c
@ $a='anew'
@ $b='bnew'
@ $c='cnew'
$a $b $c
@endfunction
@ $a='a'
@ $b='b'
@ $c='c'
$a $b $c
@ $abc( $a, $b )
$a $b $c
@push
@output "foo"
FOO
@output "stdout"
STDOUT
@pop
@push
@function decl( d )
@ push
@ output "example.h"
$d
@ pop
@endfunction
@output "example.c"
#include "example.h"
@ $decl( "int i;" )
int main()
{
@ $decl( "int result;" )
return result;
}
@pop
@function string( len )
@ if ( $len == 1 )
@ return "z"
@ else
@ return "z" + $string( $len-1 )
@ endif
@endfunction
@switch "zz"
@ case $string(1) :
1
@ break
@ case $string(2) :
2
@ break
@ case $string(3) :
3
@ break
@endswitch
$printf( "%-10s %d 0x%02X", "foo", 10, 10 )
@ $x = 1
@ $y = [ 1, 2, 3 ]
@ $z = [ a:"foo", b:10 ]
$size($x) $size($y) $size($z) $size($undef)
@ $x = 1
@ $y = "Foo Bar"
$strlen($x) $strlen($y) $strlen($undef)
$substr( "ABCDEFGHIJK", 2, 5 )
$substr( "ABCDEFGHIJK", 2 )
$substr( "ABCDEFGHIJK", 2, 50 )
$system("ps")
\#line $tplline() \"$tplfile()\"